<template>
  <div>
    <el-table :data="data" style="width: 100%" border v-loading="loading">
      <el-table-column prop="index" label="序号">
        <template slot-scope="scope">
          <div>{{ getIndex(scope.$index) }}</div>
        </template>
      </el-table-column>
      <el-table-column prop="id" label="编号"> </el-table-column>
      <el-table-column prop="title" label="标题"> </el-table-column>
      <el-table-column prop="author" label="管理员"> </el-table-column>
      <el-table-column prop="date" label="日期"> </el-table-column>
      <el-table-column prop="control" label="操作栏">
        <template slot-scope="scope">
          <el-button type="danger" size="small" @click="deletes(scope.row)"
            >删除</el-button
          >
          <el-button type="warning" size="small" @click="edit(scope.row)"
            >编辑</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <dialog-view
      :show="show"
      :title="title"
      @close="close"
      :getForm="getForm"
    />
  </div>
</template>

<script>
import dialogView from "./dialogView.vue";
export default {
  components: {
    dialogView,
  },
  props: ["data", "loading"],
  data() {
    return {
      show: false,
      title: "", //标题
      getForm: {},
    };
  },
  methods: {
    //统计
    getIndex(e) {
      return (this.$parent.pag.pageNo - 1) * this.$parent.pag.pageSize + e + 1;
    },
    deletes(e) {
      this.$emit("deletes", e);
    },
    //编辑
    edit(e) {
      this.show = true;
      this.title = "通知-编辑";
      console.log(e, "eeee");
      this.getById(e.id);
    },
    getById(e) {
      this.$http.post("getSingNotice", { id: e }).then((res) => {
        if (res.code == 200) {
          console.log(res);
          this.getForm = res.data.data;
        }
      });
    },
    //关闭
    close(e) {
      if (e) {
        this.show = false;
      }
    },
  },
};
</script>

<style scoped>
</style>